<?php

class BaseWidget extends CWidget
{
    public $template;
    public $templateName;

    public function __construct($owner=null)
    {
        $this->template = new Template;
        parent::__construct($owner);
    }

    public function render($viewName, $data = null, $return = false)
    {
        if ( $this->templateName )
        {
            $viewName = $this->templateName;
        }

        $themeName = Yii::app()->theme->name;

        echo parent::render('webroot.themes.'.$themeName.'.templates.widgets.'.ucfirst($viewName), $data, $return);
          
    } 

    public function run()
    {
        $this->render(get_class($this), $this->template->getTemplateData());
    }
}